<template>
  <div>
    <router-link :to="'/saleChance/AddSalePlan?cid='+saleChanceId"><el-button>添加</el-button></router-link>
    <el-table
      :data="salePlanList"
      :stripe="true"
      style="width: 100%">
      <el-table-column
        prop="id"
        label="编号">
      </el-table-column>
      <el-table-column
        prop="title"
        label="计划名称">
      </el-table-column>
      <el-table-column
        prop="description"
        label="计划描述">
      </el-table-column>
      <el-table-column
        prop="execution"
        label="执行情况">
      </el-table-column>
      <el-table-column
        prop="executionDescription"
        label="结果的描述">
      </el-table-column>

      <el-table-column
        label="操作">
        <template slot-scope="scope">
          <el-button @click="deleteById(scope.row.id)" size="mini">删除</el-button>
        </template>
      </el-table-column>
    </el-table>
    <router-view/>
  </div>
</template>

<script>
    export default {
        name: "salePlanList",
      data(){
          return {
            salePlanList:[],
            saleChanceId:""
          }
      },
      created(){
        this.selectPlanByCid();
        this.saleChanceId=this.$route.query.cid
      },
      methods:{
        deleteById(id){
          this.axios.delete("/salePlan/delete/"+id).then((resp)=>{
            //提示保存成功信息
            this.$message.success("删除成功！");
            this.selectPlanByCid();
          });
        },
        selectPlanByCid(){
          //发出ajax请求请求后端代码
          this.axios.get("/salePlan/selectByCid/"+this.$route.query.cid).then((resp)=>{
            this.salePlanList=resp.data;
          });
        }
      }
    }
</script>

<style scoped>

</style>
